import time

from selenium.webdriver.common.by import By

from base.app_base_page import AppBasePage


class  PagePay(AppBasePage):

    def __init__(self,driver):
        super().__init__(driver)
        # 点击立即购买
        self.h=By.XPATH,'//android.widget.TextView[@resource-id="com.tpshop.malls:id/buy_tv"]'
        # 点击提交订单
        self.i=By.XPATH,'//android.widget.TextView[@resource-id="com.tpshop.malls:id/submit_tv"]'
        # 点击支付
        self.j=By.XPATH,'//android.widget.Button[@resource-id="com.tpshop.malls:id/pay_btn"]'
        # 输入支付密码
        self.k=By.ID,'com.tpshop.malls:id/pwd_et'
        # 点击确定
        self.l=By.XPATH,'//android.widget.TextView[@resource-id="com.tpshop.malls:id/sure_tv"]'
        # # 获取订单确认成功
        self.m=By.ID,'com.tpshop.malls:id/title_tv'

    def app_page_pay(self,password):
        self.app_base_click(self.h)
        self.app_base_click(self.i)
        self.app_base_click(self.j)
        self.app_base_input(self.k,password)
        self.app_base_click(self.l)

    def app_page_pay_success(self):
        time.sleep(1)
        aa=self.app_fd_element(self.m).text
        return aa